package excel.poi;

import org.apache.poi.hssf.usermodel.HSSFWorkbook;
import org.apache.poi.ss.usermodel.Cell;
import org.apache.poi.ss.usermodel.Row;
import org.apache.poi.ss.usermodel.Sheet;
import org.apache.poi.ss.usermodel.Workbook;
import org.apache.poi.xssf.usermodel.XSSFWorkbook;

import java.io.FileOutputStream;
import java.io.IOException;

/**
 * @Author Klys
 * @Date 2023/4/26 14:43
 * @Description
 * @Version 1.0
 */
public class TestWrite07 {
    final static String PATH = "D:\\Typora学习笔记\\Java面试笔记\\java面试笔记练习代码\\Interview\\src\\main\\java\\excel\\file\\";

    public static void main(String[] args) throws IOException {
        //1、创建一个工工作簿
        Workbook workbook = new XSSFWorkbook();
        //2、创建一个工作表
        Sheet sheet = workbook.createSheet("07统计表1");
        //3、创建一个行
        Row row1 = sheet.createRow(0); //0代表第一行
        //4、创建一个单元格
        Cell cell1 = row1.createCell(0);  //定位到了（1，1）
        cell1.setCellValue("员工姓名");
        Row row2 = sheet.createRow(1); //1代表第二行
        Cell cell2 = row2.createCell(0);  //(2,1)
        cell2.setCellValue("klys");
        //03以.xlsx结尾
        FileOutputStream fileOutputStream = new FileOutputStream(PATH + "excl07结果表.xlsx");

        workbook.write(fileOutputStream);

        fileOutputStream.close();
        System.out.println("文件生成完毕！！！");
    }
}
